package cn.tedu.springioc;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class SpringRunner {
    public static void main(String[] args) {
        //启动Spring
        /*
          创建AnnotationConfigApplicationContext对象创建Spring容器，务必提供配置文件
          spring容器管理的对象的结构：K(Bean Id)-V(对象的内存地址值)
          getBean("beanId")
         */
        AnnotationConfigApplicationContext acac = new AnnotationConfigApplicationContext(SpringConfig.class);
        //从Spring容器中获取DemoBean类型的对象的三种方法，如果对象能获取到，说明Spring运行时完全正常的！
        //快速生成变量的快捷键：CTRL+ALT+V
//        DemoBean bean1 = acac.getBean(DemoBean.class);
//        DemoBean bean2 = (DemoBean) acac.getBean("demoBean");
        DemoBean bean3 = acac.getBean("demoBean", DemoBean.class);
//        System.out.println(bean1);
//        System.out.println(bean2);
        DemoBean bean4 = acac.getBean("demoBean", DemoBean.class);
        DemoBean bean5 = acac.getBean("demoBean", DemoBean.class);
        System.out.println(bean3);
        System.out.println(bean4);
        System.out.println(bean5);
    }
}
